package com.wallet.trans.producer;

import com.alibaba.fastjson.JSONObject;
import com.wallet.trans.domain.ProducerMqMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class TransMqProducer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Value("${trans.push_response_topic}")
    private String push_response_topic;

    public void send(ProducerMqMessage producerMqMessage){
        try {
            //推送消息
            rocketMQTemplate.syncSend(push_response_topic,  producerMqMessage);
        } catch (Exception ex) {
            //由生产者直接发送
            throw new RuntimeException(ex);
        }
    }
}
